package edu.uwm.universitydb.swing;

import java.util.List;

import edu.uwm.universitydb.model.Department;
import edu.uwm.universitydb.service.dept.DepartmentService;

public class DepartmentTableModel extends DataTableModel {
	

	public DepartmentTableModel(DepartmentService service) {
		super(_colNames, _colTypes);
		_departmentService = service;
	}
	

	public DepartmentService getService() {
		return _departmentService;
	}
	
	@Override
	public int getRowCount() {
		List<Department> departments = _departmentService.getDepartments();
		return departments.size();
	}
	@Override
	public Object getValueAt(int row, int col) {
		List<Department> departments = _departmentService.getDepartments();
		switch (col) {
		case 0:
			return departments.get(row).getDeptName();
		default:
			return "Error";
		}
		
	}
	
	private static final String[] _colNames = new String[] {"Department"};
	private static final Class<?>[] _colTypes = new Class<?>[] {String.class};
	
	private static final long serialVersionUID = 2650564265612683458L;


	private final DepartmentService _departmentService;

}
